package ${controllerPath};

import ${modelPath}.${EntityName};
import ${servicePath}.${EntityName}Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import com.base.web.core.common.JsonResult;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 *
 * @Author: Generator
 * @Date ${.now?string('yyyy-MM-dd hh:mm:ss')}
 */

@RestController
@RequestMapping("/${entityName}")
public class ${EntityName}Controller {

    private Logger logger = LoggerFactory.getLogger(${EntityName}Controller.class);

	@Autowired
	private ${EntityName}Service ${entityName}Service;

    @GetMapping(value = "/list")
    public JsonResult getList(${EntityName} bean){
        List<${EntityName}> list = ${entityName}Service.select(bean);
        return JsonResult.success(list);
    }

    @PostMapping(value = "/add")
    public JsonResult addOne(${EntityName} bean){
        Integer count = ${entityName}Service.insertSelective(bean);
        return JsonResult.success(count);
    }

    @PostMapping(value = "/edit")
    public JsonResult editOne(${EntityName} bean){
        Integer count = ${entityName}Service.updateByPrimaryKeySelective(bean);
        return JsonResult.success(count);
    }

    @PostMapping(value = "/del")
    public JsonResult deleteOne(String id){
        Integer count = ${entityName}Service.deleteByPrimaryKey(id);
        return JsonResult.success(count);
    }

    @RequestMapping("/${entityName}Manager")
    public String ${entityName}Manage() {
        return "${entityName}/${entityName}Manager";
    }

    @RequestMapping("/${entityName}Add")
    public String ${entityName}Add() {
        return "${entityName}/${entityName}Add";
    }

    @RequestMapping("/${entityName}Edit")
    public String ${entityName}Edit() {
        return "${entityName}/${entityName}Edit";
    }

}